package org.testis.gui.mvc.model.testdesign;

import org.testis.gui.mvc.model.*;
import org.testis.gui.mvc.controller.testdesign.RunningTestSuiteController;
import org.testis.testdriver.AtofEnumaration.ExecutionInterventionType;

/**
 *
 * @author Cahit Emir Erel
 */
public class RunningTestSuiteModel extends AbstractModel {

    private Boolean m_running = false;
    private Boolean m_runTestSuiteVisibility = false;
    private String m_mode = "";
    private String m_output = "";
    private Boolean m_abortEnability = false;
    private Boolean m_retryEnability = false;
    private Boolean m_continueEnability = false;
    private ExecutionInterventionType m_runningState =null;

    public void setTestEnd(Boolean testEnd) {
        if (testEnd != null && testEnd) {
            firePropertyChange(RunningTestSuiteController.TEST_END,
                    false,
                    true);
        }
    }

    public String getMode() {
        return m_mode;
    }

    public void setMode(String mode) {
        if (mode == null) {
            mode = "";
        }
        String oldMode = m_mode;
        m_mode = mode;
        firePropertyChange(RunningTestSuiteController.CHANGE_MODE,
                oldMode,
                mode);
    }

    public String getOutput() {
        return m_output;
    }

    public void setOutput(String output) {
        if (output == null) {
            output = "";
        }
        String oldOutput = m_output;
        m_output = output;
        firePropertyChange(RunningTestSuiteController.CHANGE_OUTPUT,
                null,
                output);
    }

    public void setRunTestSuiteVisibility(Boolean runTestSuiteVisibility) {
        if (runTestSuiteVisibility == null) {
            return;
        }
        Boolean oldRunTestSuiteVisibility = m_runTestSuiteVisibility;
        m_runTestSuiteVisibility = runTestSuiteVisibility;
        firePropertyChange(RunningTestSuiteController.SHOW_RUN_TEST_SUITE,
                oldRunTestSuiteVisibility,
                runTestSuiteVisibility);
    }

    public Boolean getRunTestSuiteVisibility() {
        return m_runTestSuiteVisibility;
    }

    public Boolean getRunning() {
        return m_running;
    }

    public void setRunning(Boolean running) {
        if (running == null) {
            return;
        }
        Boolean oldRunning = m_running;
        m_running = running;
        firePropertyChange(RunningTestSuiteController.IS_RUNNING,
                oldRunning,
                running);
    }

    public Boolean getAbortEnability() {
        return m_abortEnability;
    }

    public void setAbortEnability(Boolean abortEnability) {
        Boolean oldValue = m_abortEnability;
        m_abortEnability = abortEnability;
        firePropertyChange(RunningTestSuiteController.ENABLE_ABORT_BUTTON,
                oldValue,
                m_abortEnability);

    }

    public Boolean getRetryEnability() {
        return m_retryEnability;
    }

    public void setRetryEnability(Boolean retryEnability) {
        Boolean oldValue = m_retryEnability;
        m_retryEnability = retryEnability;
        firePropertyChange(RunningTestSuiteController.ENABLE_RETRY_BUTTON,
                oldValue,
                m_retryEnability);

    }

    public Boolean getContinueEnability() {
        return m_continueEnability;
    }

    public void setContinueEnability(Boolean continueEnability) {
        Boolean oldValue = m_continueEnability;
        m_continueEnability = continueEnability;
        firePropertyChange(RunningTestSuiteController.ENABLE_CONTINUE_BUTTON,
                oldValue,
                m_continueEnability);

    }

    /**
     * @return the m_runningState
     */
    public ExecutionInterventionType getRunningState() {
        return m_runningState;
    }

    /**
     * @param m_runningState the m_runningState to set
     */
    public void setRunningState(ExecutionInterventionType runningState) {
        ExecutionInterventionType oldrunningState = m_runningState;
        m_runningState = runningState;
        firePropertyChange(RunningTestSuiteController.CHANGE_STATE,
                oldrunningState,
                m_runningState);
    }
}
